2f14074109b7e56cf56ea3e565981048ac746cdc,opennms-services/src/main/java/org/opennms/netmgt/poller/monitors/AsteriskSIPPeerMonitor.java,AsteriskSIPPeerMonitor,poll,#MonitoredService#Map#,114

Before Change


		AmiAgentConfig amiConfig = amiPeerFactory.getAgentConfig(svc.getAddress());

		//setting up AMI connection	
		log().debug(svc.getSvcName() + ": Creating new AMI-Connection: " + svc.getIpAddr() + ":" + amiConfig.getPort() + ", " + amiConfig.getUsername() + "/" + amiConfig.getPassword());
		ManagerConnectionFactory factory = new ManagerConnectionFactory(svc.getIpAddr(), amiConfig.getPort(), amiConfig.getUsername(), amiConfig.getPassword());
		ManagerConnection managerConnection;
		if(amiConfig.getUseTls())
		{
                	managerConnection = factory.createSecureManagerConnection();
		}
		else
		{
                	managerConnection = factory.createManagerConnection();
		}
		managerConnection.setSocketTimeout(new Long(timeoutTracker.getTimeoutInMillis()).intValue());

		//start with polling
		while(timeoutTracker.shouldRetry())
		{
			timeoutTracker.nextAttempt();
			log().debug(svc.getSvcName() + ": Attempt " + timeoutTracker.getAttempt());
			try
			{
				log().debug(svc.getSvcName() + ": AMI login");
	                	managerConnection.login();

				log().debug(svc.getSvcName() + ": AMI sendAction SipShowPeer");
                		ManagerResponse response = managerConnection.sendAction(new SipShowPeerAction(sipPeer));
				if(response.getAttribute("Status") == null)
				{
					log().debug(svc.getSvcName() + ": service status down");
					return PollStatus.decode("Down", "State of SIP Peer is unknown, because it was not found on the Asterisk server");

				}
				log().debug(svc.getSvcName() + ": Response: " + response.getAttribute("Status"));

				log().debug(svc.getSvcName() + ": AMI logoff");
	               		managerConnection.logoff();

                		if (response.getAttribute("Status").startsWith("OK"))
                		{
					log().debug(svc.getSvcName() + ": service status up");
					return PollStatus.decode("Up", "OK");
	                	}
        	        	else
                		{
					log().debug(svc.getSvcName() + ": service status down");
					return PollStatus.decode("Down", "State of SIP Peer is " + response.getAttribute("Status") + " and not OK");
	                	}
			}
			catch(AuthenticationFailedException e)
			{
				log().error(svc.getSvcName() + ": AMI AuthenticationError: " + e.toString());
				return PollStatus.decode("Down", "Could not get the state of SIP Peer: AMI AuthenticationError");
			}
			catch(TimeoutException e)

After Change


		AmiAgentConfig amiConfig = amiPeerFactory.getAgentConfig(svc.getAddress());

		//setting up AMI connection	
		LOG.debug("{}: Creating new AMI-Connection: {}:{}, {}/{}", svc.getSvcName(), svc.getIpAddr(), amiConfig.getPort(), amiConfig.getUsername(), amiConfig.getPassword());
		ManagerConnectionFactory factory = new ManagerConnectionFactory(svc.getIpAddr(), amiConfig.getPort(), amiConfig.getUsername(), amiConfig.getPassword());
		ManagerConnection managerConnection;
		if(amiConfig.getUseTls())
		{
			managerConnection = factory.createSecureManagerConnection();
		}
		else
		{
			managerConnection = factory.createManagerConnection();
		}
		managerConnection.setSocketTimeout(new Long(timeoutTracker.getTimeoutInMillis()).intValue());

		//start with polling
		while(timeoutTracker.shouldRetry())
		{
			timeoutTracker.nextAttempt();
			LOG.debug("{}: Attempt {}", svc.getSvcName(), timeoutTracker.getAttempt());
			try
			{
				LOG.debug("{}: AMI login", svc.getSvcName());
				managerConnection.login();

				LOG.debug("{}: AMI sendAction SipShowPeer", svc.getSvcName());
				ManagerResponse response = managerConnection.sendAction(new SipShowPeerAction(sipPeer));
				if(response.getAttribute("Status") == null)
				{
					LOG.debug("{}: service status down", svc.getSvcName());
					return PollStatus.decode("Down", "State of SIP Peer is unknown, because it was not found on the Asterisk server");

				}
				LOG.debug("{}: Response: {}", svc.getSvcName(), response.getAttribute("Status"));

				LOG.debug("{}: AMI logoff", svc.getSvcName());
				managerConnection.logoff();

				if (response.getAttribute("Status").startsWith("OK"))
				{
					LOG.debug("{}: service status up", svc.getSvcName());
					return PollStatus.decode("Up", "OK");
				}
				else
				{
					LOG.debug("{}: service status down", svc.getSvcName());
					return PollStatus.decode("Down", "State of SIP Peer is " + response.getAttribute("Status") + " and not OK");
				}
			}
			catch(AuthenticationFailedException e)
			{
				LOG.debug("{}: AMI AuthenticationError.", svc.getSvcName(), e);
				return PollStatus.decode("Down", "Could not get the state of SIP Peer: AMI AuthenticationError");
			}
			catch(TimeoutException e)